void SkinBitmap::stretchRectToRect(CanvasBase *canvas, RECT *src, RECT *dst) {
stretchToRectAlpha(canvas,src,dst,255);
}
void SkinBitmap::stretchToRectAlpha(CanvasBase *canvas, RECT *r, int alpha) {
RECT re;
re.left=0; re.top=0;
re.right=getWidth(); re.bottom=getHeight();
stretchToRectAlpha(canvas,&re,r,alpha);
}
void SkinBitmap::blitAlpha(CanvasBase *canvas, int x, int y, int alpha)
{
RECT dst,src;
dst.left=x;
dst.top=y;
src.left=0;
src.top=0;
src.bottom=getHeight();
src.right=getWidth();
blitToRect(canvas,&src,&dst,alpha);
}
#pragma warning(push)
#pragma warning(disable : 4799)
template <class C>
class Stretcher {
public:
static void _stretchToRectAlpha(SkinBitmap *bitmap, int ys, int ye, int xe, int xs, int xstart, int yv, void *dib, int cwidth, int dxv, int dyv, int alpha) {
int bitmap_x = bitmap->getX();
int bitmap_y = bitmap->getY();
int bmpheight = bitmap->getHeight();
int fullimage_w = bitmap->getFullWidth();
void *bits = bitmap->getBits();
int xp=xe-xs;
for (int yp = ys; yp < ye; yp ++) {
int t=yv>>16;
if (t < 0) t=0;
if (t >= bmpheight) t=bmpheight-1;
int *psrc=((int*)bits) + (t+bitmap_y)*fullimage_w + bitmap_x;
int *dest=((int*)dib) + cwidth*yp + xs;
C::stretch(xp, psrc, dest, xstart, dxv, alpha);
yv+=dyv;
}
}
};
// no alpha, just stretch
class Stretch {
public:
static void stretch(int xp, int *psrc, int *dest, int xv, int dxv, int alpha) {
while (xp--) { //JFtodo: assembly optimize - these first two modes aren't used that much anyway
*dest++ = psrc[xv>>16];
xv+=dxv;
}
}
};
// no alpha channel, just a global alpha val
class StretchGlobal {
public:
static void stretch(int xp, int *psrc, int *dest, int xv, int dxv, int alpha) {
while (xp--) { //JFTODO: make MMX optimized version